class Book:
    def __init__(self,title,author,isbn):
        self.title=title
        self.author=author
        self.__isbn=isbn
        self.is_borrowed=False

    def get_isbn(self):
        return self.__isbn
    def borrow(self):
        if self.is_borrowed:
            return False
        self.is_borrowed=True
        return True
    def return_book(self):
        if not self.is_borrowed:
            return False
        self.is_borrowed=False
        return True
    def __str__(self):
        return f"{self.title} by {self.author} (ISBN: {self.__isbn}) - {'已借出' if self.is_borrowed else '可借阅'}"


class Library:
    def __init__(self):
        self.books=[]
    def add_book(self,book):
        if any(b.get_isbn()==book.get_isbn() for b in self.books):
            print("添加失败，已存在")
        else:
            print(f"添加成功")
    def find_by_author(self,author):
        found_books=[book for book in self.books if book.author==author]
        return sorted(found_books,key=lambda b:b.title)
